package huawei.window;

import java.util.ArrayList;

public class J1456 {
    private static final int[] VOWELS= new int[128];
    static {
        VOWELS['a']=1;
        VOWELS['e']=1;
        VOWELS['i']=1;
        VOWELS['o']=1;
        VOWELS['u']=1;
    }

    /**
     * 思路:滑动窗口无疑问.
     * 判断元音: 1.ArrayList<
     */
    public int maxVowels(String s, int k) {
        int maxVowels=0;
        int curVowels=0;
        int[] contains =new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            contains[i]=VOWELS[s.charAt(i)];
        }
        for (int i = 0; i < s.length(); i++) {
            curVowels+=contains[i];

            if(i+1>=k){
                maxVowels=Math.max(maxVowels,curVowels);
                //下次循环不需要的数据
                curVowels-=contains[i+1-k];
            }
        }
        return maxVowels;
    }
}
